--TEST--
string MySQLndUhConnection::getStatistics(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function _getStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return parent::getStatistics($res);
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function getStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			$stats = array("my" => "stats");
			return $stats;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function getStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
		}
	}

	class proxy4 extends MySQLndUhConnection {
		public function getStatistics($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			return -1;
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	$stats = $conn->get_connection_stats();
	printf("stats: %s/%s\n", gettype($stats), (count($stats) > 20) ? 'reasonable' : 'too small');
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	$stats = $conn->get_connection_stats();
	printf("stats: %s/%s\n", gettype($stats), (count($stats) > 20) ? 'reasonable' : 'too small');
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	$stats = $conn->get_connection_stats();
	var_dump($stats);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	$stats = $conn->get_connection_stats();
	var_dump($stats);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	$stats = $conn->get_connection_stats();
	var_dump($stats);
	mysqlnd_uh_test\query_test::mysqli($conn);

	print "done!";
?>
--EXPECTF--
stats: array/reasonable
stats: array/reasonable
proxy2::getStatistics(array (
  0 => NULL,
))
array(1) {
  ["my"]=>
  string(5) "stats"
}
proxy3::getStatistics(array (
  0 => NULL,
))

Warning: mysqli::get_connection_stats(): (MySQLnd User Handler) The MySQLndUhConnection::getStatistics() callback did not return an array as it should in %s on line %d
NULL
proxy4::getStatistics(array (
  0 => NULL,
))

Warning: mysqli::get_connection_stats(): (MySQLnd User Handler) The MySQLndUhConnection::getStatistics() callback did not return an array as it should in %s on line %d
NULL
done!